### Servo test   grytole@gmail.com   03-Nov-2013 ###

TARGET = i2cservo
DEVICE = attiny2313a
F_CPU = 8000000
CFLAGS = -Wall -Os -DF_CPU=$(F_CPU) -I. -mmcu=$(DEVICE)
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES: .c=.o)

### Build targets ###

all: $(TARGET) $(SOURCES)

$(TARGET): $(OBJECTS)
	rm -f *.hex
	avr-gcc $(CFLAGS) $(OBJECTS) -o $@.elf
	avr-objcopy -j .text -j .data -O ihex $@.elf $@.hex
	avr-size --mcu=$(DEVICE) $@.hex

.c.o:
	avr-gcc $(CFLAGS) -c $< -o $@

clean:
	rm -f *.hex *.lst *.obj *.cof *.list *.map *.elf *.o

### eof ###